<%-- 
  - Author: Neha Chauhan
  - Date: 13-Apr-'2011
  - Copyright Notice: TRAKHEES
  - Description: form.jsp
 --%>

<%@ include file="/WEB-INF/view/include.jsp"%>
<%@ page import="ae.pcfc.etks.online.web.*"%>

<c:choose>
	<c:when
		test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
		<script language="Javascript" type="text/javascript"
			src='<c:url value="/resources/js/jqgrid/grid.locale-ar.js"/>'></script>
	</c:when>
	<c:otherwise>
		<script language="Javascript" type="text/javascript"
			src='<c:url value="/resources/js/jqgrid/grid.locale-en.js"/>'></script>
	</c:otherwise>
</c:choose>

<script language="Javascript" type="text/javascript"
	src='<c:url value="/resources/js/jqgrid/jquery.jqGrid.min.js"/>'></script>

<script type="text/javascript">
	$().ready(function() {
		
		//$("input:submit, input:reset, input:button, input:file").button();
		
		$('#grid')
		.jqGrid(
				{
					datatype : function(postdata) {
						$
								.ajax({
									type : "POST",
									url : "admin/general/user/role/update/displayUsersTable.json?page="
											+postdata.page+"&rows="+postdata.rows+"&sidx="+postdata.sidx+"&sord="+postdata.sord,
									cache:false,
									contentType:"application/json",
									dataType : "json",														
									success : function(
											data) {
										var thegrid = jQuery("#grid")[0];
										
										thegrid
												.addJSONData(data);


									}
								});
					},
					colNames : [ '<spring:message code="label.username" />',
									'<spring:message code="label.emailaddress" />','<spring:message code="label.accountstatus" />','<spring:message code="label.clienttype" />' ],
					
					colModel : [ {

						index : '<spring:message code="label.username" />',
						width : 60,
						align : 'center',
						editable : true,
						editrules : {
							edithidden : false
						}
					}, {

						index : '<spring:message code="label.emailaddress" />',
						width : 400,
						align : 'center',
						sortable : true,
						editable : true,
						edittype : 'text',
						editrules : {
							required : true
						}
					},{

						index : '<spring:message code="label.accountstatus" />',
						width : 400,
						align : 'center',
						sortable : true,
						editable : true,
						edittype : 'text',
						editrules : {
							required : true
						}
					},{

						index : '<spring:message code="label.clienttype" />',
						width : 400,
						align : 'center',
						sortable : true,
						editable : true,
						edittype : 'text',
						editrules : {
							required : true
						}
					}],
					pager: '#pager',
					autowidth : true,
					height : "auto",

					rowNum : 10,
					rowList : [ 5, 10, 20, 50 ],
					sortname : '<spring:message code="label.username" />',
					sortorder : "desc",
					viewrecords : true,
					multiselect : false,
					scrollOffset : 0,
					<c:if
					test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
					//direction:'rtl',
					</c:if>
					//caption : '<spring:message code="label.serviceattributes" />'
				}).navGrid('#pager', {
			edit : false,
			add : false,
			del : false,
			search : true
		}),
		$("#grid").navButtonAdd('#pager',
				   {  caption:"Delete",
				    buttonicon:"ui-icon-trash",
				    onClickButton: deleteRow,
				    position: "last",
				    title:"",
				    cursor: "pointer"
				   }
				  );

		
		$("#UpdateUserRole").validate({
			onfocusout:false,
			onkeyup:false,
			onclick: false,			
			rules : {
				strUserName : "required",
				strEmail : "required"
				
			},
			showErrors : function(errorMap, errorList) {

				var errors = '<ul>';
				var label;
				if (errorList.length) {
					$.each(errorMap, function(name, value) {
						label = $("label[for='" + name + "']").html();
						label = value + '[' + label + ']';
						errors = errors + '<li>' + label + '</li>';

					});
					errors = errors + '</ul>';
					jAlert('error', errors, '<spring:message code="label.errormessage" />');
				}
			}
		});
	});
	

</script>



<div id="container" dir='<spring:message code="page.dir"/>'  align='<spring:message code="page.align"/>' class="roundBorderBox">


<form:form name="UpdateUserRole" id="UpdateUserRole" method="POST" 
		modelAttribute="<%=ConstantsAdmin.ADMIN_UPDATE_USER_ROLE_MODEL_KEY %>">
		
		
		<spring:hasBindErrors
			name="<%=ConstantsAdmin.ADMIN_UPDATE_USER_ROLE_MODEL_KEY %>">
			<script type="text/javascript">
				$(document)
						.ready(
								function() {
									jAlert(
											'error',
											'<li><form:errors path="*" delimiter="<li>"/>',
											'<spring:message code="label.errormessage" />');
								});
			</script>
		</spring:hasBindErrors>
		
		
	
	<fieldset>
			<legend><spring:message code="label.updaterole.search" /></legend>
	</fieldset>
		
		<table border="0">
		
		
			<tr>
			
			<td><div class="fm-req"><form:label path="strUserName">
			<spring:message code="label.username" /></form:label></div></td>
			<td><form:input path="strUserName" id="strUserName" size="20"
					maxlength="100" /></td>
		  
		   
		   <td><div class="fm-req"><form:label path="strEmail">
				<spring:message code="label.emailaddress" /></form:label></div></td>
		 	<td><form:input path="strEmail" id="strEmail" size="20"
					maxlength="100" /></td>
		  </tr>
		
		 </table>  
	  
	    <div id="fm-submit" class="fm-req">
				<input type="submit" name="search" value="<spring:message code="label.button.search" />" class="t_btns search"/>
				<input type="reset" name="reset" value="<spring:message code="label.button.reset" />" class="t_btns reset"/>				
		</div>
	
	    <br><br>
	    
	<div id="search"></div>
			<table id="grid">
			</table>
			<span id="pager"></span>
	
	

	</form:form>
</div>
